/**
 *
 */
package com.whosly.api.exception;

import com.whosly.api.enums.IResultCodeType;
import lombok.Getter;
import lombok.Setter;

/**
 * 基础异常
 *
 * @author yueny09 <yueny09@163.com>
 *
 * @DATE 2018年4月18日 上午12:56:38
 *
 */
public class BaseHolderException extends Exception implements ILangException {
	/**
	 *
	 */
	private static final long serialVersionUID = 1193049181152700746L;

	/**
	 * 错误码
	 */
	@Getter
	@Setter
	private String errorCode;
	/**
	 * 错误描述
	 */
	@Getter
	@Setter
	private String errorMsg;

	/**
	 * @param errorType
	 *            错误枚举
	 */
	public BaseHolderException(final IResultCodeType errorType) {
		super(errorType.getMessage());

		this.errorCode = errorType.getCode();
		this.errorMsg = errorType.getMessage();
	}

	public BaseHolderException(final String errorMsg) {
		super(errorMsg);
		this.errorMsg = errorMsg;
	}

	/**
	 * @param errorCode
	 *            错误码
	 * @param errorMsg
	 *            错误描述
	 */
	public BaseHolderException(final String errorCode, final String errorMsg) {
		super(errorMsg);

		this.errorCode = errorCode;
		this.errorMsg = errorMsg;
	}

	public BaseHolderException(final Throwable cause) {
		super(cause);
		this.errorMsg = cause.getMessage();
	}

}
